package com.zys.http.extension.gutter;

import com.intellij.codeInsight.daemon.GutterName;
import com.intellij.codeInsight.daemon.LineMarkerInfo;
import com.intellij.codeInsight.daemon.LineMarkerProviderDescriptor;
import com.intellij.psi.PsiElement;
import com.zys.http.extension.service.Bundle;
import com.zys.http.processor.ProcessorContext;
import com.zys.http.ui.icon.HttpIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

/**
 * @author zhou ys
 * @since 2023-10-12
 */
public class HttpLineMarkerProvider extends LineMarkerProviderDescriptor {
    private final Option httpGenerate = new Option("http.generate", "ApiTool", HttpIcons.HttpMethod.REQUEST);

    @Override
    public LineMarkerInfo<?> getLineMarkerInfo(@NotNull PsiElement element) {
        return httpGenerate.isEnabled() ? ProcessorContext.createLineMarkerInfo(element) : null;
    }

    @Override
    public @Nullable("null means disabled") @GutterName String getName() {
        return Bundle.get("http.extension.gutter");
    }

    @Override
    public @Nullable Icon getIcon() {
        return HttpIcons.HttpMethod.REQUEST;
    }
}
